package kr.hkit.powerjava.chapter26.common;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBUtil {

	public static void close(Connection con){
		if(con != null){
			try {
				con.close();
			} catch (SQLException e) {
				System.err.print(e);
			} finally{
				con = null;
				System.out.println("MySQL Connection Close");
			}
		}
	}
	
	public static void close(PreparedStatement pstmt){
		if(pstmt != null){
			try {
				pstmt.close();
			} catch (SQLException e) {
				System.err.print(e);
			} finally{
				pstmt = null;
			}
		}
	}
	
	public static void close(PreparedStatement pstmt, Connection con){
		close(pstmt);
		close(con);
	}

	public static void close(ResultSet rs, PreparedStatement pstmt, Connection connection) {
		close(rs);
		close(pstmt,connection);
	}

	public static void close(ResultSet rs) {
		
	}
}
